import global from "../../global";
import Player from "../battle/player";
import TouchSkill from "./touchSkill";

const {ccclass, property} = cc._decorator;

@ccclass
export default class PlayerMessage extends cc.Component {

    @property(cc.Node)
    Color:cc.Node = null;       //代表颜色
    @property(cc.Node)
    Frame:cc.Node = null;       //提示谁的回合的框
    @property(cc.Node)
    BG:cc.Node = null;          //提示谁的回合的白色背景

    @property(cc.Sprite)
    Sprite_skill1:cc.Sprite = null; //技能1
    @property(cc.Sprite)
    Sprite_skill2:cc.Sprite = null; //技能2
    @property(cc.Sprite)
    Sprite_skill3:cc.Sprite = null; //技能3
    @property(cc.Sprite)
    Sprite_skill4:cc.Sprite = null; //技能4

    /**
     * 初始化，赋值进来
     */
    init(player:Player){
        player.playerMessage = this;
        this.Color.color = player.color;
        //换图片
        global.loadSf(this.Sprite_skill1,`/skill/${player.skill1.bh}`);
        global.loadSf(this.Sprite_skill2,`/skill/${player.skill2.bh}`);
        global.loadSf(this.Sprite_skill3,`/skill/${player.skill3.bh}`);
        global.loadSf(this.Sprite_skill4,`/skill/${player.skill4.bh}`);
        //给按钮传数据进去
        this.Sprite_skill1.node.getComponent(TouchSkill).skill = global.getJsonSkill(player.skill1.bh);
        this.Sprite_skill2.node.getComponent(TouchSkill).skill = global.getJsonSkill(player.skill2.bh);
        this.Sprite_skill3.node.getComponent(TouchSkill).skill = global.getJsonSkill(player.skill3.bh);
        this.Sprite_skill4.node.getComponent(TouchSkill).skill = global.getJsonSkill(player.skill4.bh);
    }

    /**
     * 显示和隐藏回合提示框
     */
    showFrame(){
        this.Frame.active = true;
        this.BG.active = true;
    }
    hideFrame(){
        this.Frame.active = false;
        this.BG.active = false;
    }
}
